import { createRouter, createWebHistory, RouteRecordRaw, RouteLocationNormalized } from 'vue-router'
import Home from '@/views/Home.vue'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('@/views/About.vue')
  },
  {
    path: '/timer',
    name: 'TimerCount',
    component: () => import('@/views/TimerCount.vue')
  },
  {
    path: '/message',
    name: 'MessageBind',
    component: () => import('@/views/MessageBind.vue')
  }
  ,
  {
    path: '/compute',
    name: 'ComputeVue',
    component: () => import('@/views/ComputeVue.vue')
  },
  {
    path: '/watch',
    name: 'WatchVue',
    component: () => import('@/components/render/RenParent.vue')
  },
  {
    path: '/clzzObject',
    name: 'clzzObject',
    component: () => import('@/views/ClassObject.vue')
  }
]

const router = createRouter({
  history: createWebHistory('/'),
  routes
})
NProgress.configure({ showSpinner: false })
router.beforeEach(async (to: RouteLocationNormalized, _: RouteLocationNormalized, next: any) => {
  NProgress.start()
  next()
  NProgress.done()
})
router.afterEach((to: RouteLocationNormalized) => {
  console.log(to)
  NProgress.done()
})

export default router
